|
ARD2
1.00 for Rev B. Hardware
Airbag Reference Demonstrator using MPC5604P
|
00001 00017 #ifndef _SWT_H 00018 #define _SWT_H 00019 00020 /* 00021 ****************************************************************************** 00022 * Defines, Macros and Typedefs 00023 *****************************************************************************/ 00024 /*** Constant Macros ***/ 00025 /* Default Yes and No defines */ 00026 #ifndef TRUE 00027 #define TRUE (1u) 00028 #endif 00029 #ifndef CLEAR 00030 #define CLEAR (0u) 00031 #endif 00032 #ifndef BITS_IN_NIBBLE 00033 #define BITS_IN_NIBBLE (4u) 00034 #endif 00035 #ifndef BITS_IN_BYTE 00036 #define BITS_IN_BYTE (8u) 00037 #endif 00038 #ifndef BITS_IN_32 00039 #define BITS_IN_32 (32u) 00040 #endif 00041 #ifndef BITS_IN_16 00042 #define BITS_IN_16 (16u) 00043 #endif 00044 #ifndef BYTES_IN_32 00045 #define BYTES_IN_32 (4u) 00046 #endif 00047 #ifndef BYTES_IN_16 00048 #define BYTES_IN_16 (2u) 00049 #endif 00050 #ifndef BIT_DEFINITION 00051 #define BIT_DEFINITION 00052 #define BIT0 (1u << 0u) 00053 #define BIT1 (1u << 1u) 00054 #define BIT2 (1u << 2u) 00055 #define BIT3 (1u << 3u) 00056 #define BIT4 (1u << 4u) 00057 #define BIT5 (1u << 5u) 00058 #define BIT6 (1u << 6u) 00059 #define BIT7 (1u << 7u) 00060 #define BIT8 (1u << 8u) 00061 #define BIT9 (1u << 9u) 00062 #define BIT10 (1u << 10) 00063 #define BIT11 (1u << 11) 00064 #define BIT12 (1u << 12) 00065 #define BIT13 (1u << 13) 00066 #define BIT14 (1u << 14) 00067 #define BIT15 (1u << 15) 00068 #define BIT16 (1u << 16) 00069 #define BIT17 (1u << 17) 00070 #define BIT18 (1u << 18) 00071 #define BIT19 (1u << 19) 00072 #define BIT20 (1u << 20) 00073 #define BIT21 (1u << 21) 00074 #define BIT22 (1u << 22) 00075 #define BIT23 (1u << 23) 00076 #define BIT24 (1u << 24) 00077 #define BIT25 (1u << 25) 00078 #define BIT26 (1u << 26) 00079 #define BIT27 (1u << 27) 00080 #define BIT28 (1u << 28) 00081 #define BIT29 (1u << 29) 00082 #define BIT30 (1u << 30) 00083 #define BIT31 (1u << 31) 00084 #endif 00085 00086 #define SWT_EN (0x00000001u) 00087 #define SWT_DIS (0x00000000u) 00088 #define SWT_DEBUG_EN (0x00000002u) 00089 #define SWT_DEBUG_DIS (0x00000000u) 00090 #define SWT_STOP_EN (0x00000004u) 00091 #define SWT_STOP_DIS (0x00000000u) 00092 #define SWT_USES_OSCILLATOR (0x00000008u) 00093 #define SWT_SOFT_LOCK_EN (0x00000010u) 00094 #define SWT_SOFT_LOCK_DIS (0x00000000u) 00095 #define SWT_HARD_LOCK_EN (0x00000020u) 00096 #define SWT_HARD_LOCK_DIS (0x00000000u) 00097 #define SWT_GENERATE_ISR_EN (0x00000040u) 00098 #define SWT_GENERATE_ISR_DIS (0x00000000u) 00099 #define SWT_WINDOWED_MODE_EN (0x00000080u) 00100 #define SWT_WINDOWED_MODE_DIS (0x00000000u) 00101 #define SWT_RESET_WHEN_INVALID (0x00000100u) 00102 #define SWT_IVOR_WHEN_INVALID (0x00000000u) 00103 #define SWT_RANDOM_KEY_EN (0x00000200u) 00104 #define SWT_RANDOM_KEY_DIS (0x00000000u) 00105 00106 #define SWT_DEFAULT_MAP_SETTING (0xFF000000u) 00107 00108 /*** Function Macros ***/ 00109 /* This macro is needed to keep the watch-dog happy */ 00110 #define FEED_WATCHDOG() { \ 00111 SWT.SR.R = (uint32_t)0xA602u; \ 00112 SWT.SR.R = (uint32_t)0xB480u; \ 00113 } 00114 00115 /* This macro is needed to clear the Soft-lock in the module */ 00116 #define SWT_CLEAR_SOFT_LOCK() { \ 00117 SWT.SR.R = (uint32_t)0xC520u; \ 00118 SWT.SR.R = (uint32_t)0xD928u; \ 00119 } 00120 /* This macro is used when configuring the module */ 00121 #define SWT_TIME_OUT_COUNTS(xx) (xx) 00122 00123 /* This macro is used when configuring the module */ 00124 #define SWT_WINDOW_COUNTS(xx) (xx) 00125 00126 /*** Enums ***/ 00127 enum SWT_LOCK_STATUS 00128 { 00129 SWT_UNLOCKED = 0u, SWT_SOFT_LOCKED, SWT_HARD_LOCKED 00130 }; 00131 /*** TypeDefs ***/ 00132 typedef union 00133 { 00134 struct 00135 { 00136 uint32_t WindowCount; 00137 uint32_t TimeOutCount; 00138 uint32_t CR; 00139 }W; 00140 struct 00141 { 00142 uint32_t WindowCount; 00143 uint32_t TimeOutCount; 00144 uint32_t Reserved2: 23; 00145 uint32_t RandomKeyModeEn: 1; 00146 uint32_t ResetWhenInvalid: 1; 00147 uint32_t WindowModeEn: 1; 00148 uint32_t GenerateIsr: 1; 00149 uint32_t HardLockEn: 1; 00150 uint32_t SoftLockEn: 1; 00151 uint32_t Reserved: 1; 00152 uint32_t StopEn: 1; 00153 uint32_t DebugEn: 1; 00154 uint32_t Enable: 1; 00155 00156 }P; 00157 00158 } SWTConfig_t; 00159 /* 00160 ****************************************************************************** 00161 * Declarations 00162 *****************************************************************************/ 00163 /*** Extern ***/ 00164 00165 /*** Globals ***/ 00166 00167 /*** Static Globals ***/ 00168 00169 /* 00170 ****************************************************************************** 00171 * Function Prototypes 00172 *****************************************************************************/ 00173 /* 00174 ****************************************************************************** 00175 * 00176 * Function: u16fnConfigSoftwareWatchDog() 00177 * 00178 */ 00187 uint16_t u16fnConfigSoftwareWatchDog(const SWTConfig_t* ptMySWTConfig); 00188 /* 00189 ****************************************************************************** 00190 * 00191 * Function: u16fnSWTLockStatus() 00192 * 00193 */ 00202 static uint16_t u16fnSWTLockStatus(void); 00203 #endif /* _FILENAME_H */